import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Alien here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Enemigos extends Actor
{
    /**
     * Act - do whatever the Alien wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    protected int resistencia;
    protected int animacion;
    public void act() 
    {
       
    }  

    public Enemigos() {
        resistencia=0;
        animacion=0;
    }

    public void move(int velocidad) {
        if (this.getX() == -50/*|| this.getX()== this.getWorld().getWidth()*/){//getWidth()/2),(getHeight()/2)
            getWorld().removeObject(this);
        }
        else {
            setLocation(this.getX()-velocidad, this.getY());
            intersecta();
        }
    }

    public void elimina() {
        getWorld().removeObject(this);

    }

    public void intersecta(){
        Actor burbujas = getOneIntersectingObject(Burbujas.class);
        if (burbujas!= null)
        {           
            getWorld().removeObject(burbujas);
        }
        Actor comida = getOneIntersectingObject(Comida.class);
        if (comida!= null)
        {           
            getWorld().removeObject(comida);
        }
        Actor tesoros = getOneIntersectingObject(Tesoros.class);
        if (tesoros!= null)
        {           
            getWorld().removeObject(tesoros);
        }

    }
    public void reduceResistencia(){
     resistencia++;   
    }
     public void dejaRegalo(){
         if(Greenfoot.getRandomNumber(2)==0)
     getWorld().addObject(new Comida(),getX(),getY());    
    }
    
}